#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>

int sum_sql(int n)
{
    sleep(1);
    return n * n;
}
int main(int argc, char const *argv[])
{
    int items[5] = {1, 2, 3, 4, 5};
    int sum = 0;
    struct timeval start, end;
    gettimeofday(&start, NULL);
    for (int i = 0; i < 5; i++)
    {
        sum += sum_sql(items[i]);
    }
    gettimeofday(&end, NULL);
    printf("sum: %d\n", sum);
    printf("运行时间: %ld\n", end.tv_sec - start.tv_sec);

    return 0;
}
